/*
 * Copyright (C) 2010-2011 Enrique Lara (enrique.posix2.lara@gmail.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
 * limitations under the License.
  */
package trs.wmata.api;

import app.timetogo.model.Agency;
import static trs.wmata.api.Util.getLname;

import org.xml.sax.helpers.DefaultHandler;

public class NextBus extends DefaultHandler {
    public static final String DIRECTIONNUM = "DirectionNum";
    public static final String DIRECTIONTEXT = "DirectionText";
    public static final String MINUTES = "Minutes";
    public static final String NEXTBUSPREDICTION = "NextBusPrediction";
    public static final String NEXTBUSRESPONSE = "NextBusResponse";
    public static final String PREDICTIONS = "Predictions";
    public static final String ROUTEID = "RouteID";
    public static final String STOPNAME = "StopName";
    public static final String VEHICLEID = "VehicleID";
    private final StringBuilder buff = new StringBuilder();
    private final Agency agency;

    public NextBus(final Agency agency) {
        this.agency = agency;
    }

    public void startElement(final String uri, final String name, final String qName) {
        String lName = getLname(name, qName);

        if (DIRECTIONNUM.equals(lName)) {
            //current_element_id = DIRECTIONNUM_ID;
        } else if (DIRECTIONTEXT.equals(lName)) {
            //current_element_id = DIRECTIONTEXT_ID;
        } else if (MINUTES.equals(lName)) {
            //current_element_id = MINUTES_ID;
        } else if (NEXTBUSPREDICTION.equals(lName)) {
            //current_element_id = NEXTBUSPREDICTION_ID;
        } else if (NEXTBUSRESPONSE.equals(lName)) {
            //current_element_id = NEXTBUSRESPONSE_ID;
        } else if (PREDICTIONS.equals(lName)) {
            //current_element_id = PREDICTIONS_ID;
        } else if (ROUTEID.equals(lName)) {
            //current_element_id = ROUTEID_ID;
        } else if (STOPNAME.equals(lName)) {
            //current_element_id = STOPNAME_ID;
        } else if (VEHICLEID.equals(lName)) {
            //current_element_id = VEHICLEID_ID;
        }

        buff.delete(0, buff.length());
    }

    public void endElement(final String uri, final String name, final String qName) {
        String lName = getLname(name, qName);

        if (DIRECTIONNUM.equals(lName)) {
            //current_element_id = DIRECTIONNUM_ID;
        } else if (DIRECTIONTEXT.equals(lName)) {
            //current_element_id = DIRECTIONTEXT_ID;
        } else if (MINUTES.equals(lName)) {
            //current_element_id = MINUTES_ID;
        } else if (NEXTBUSPREDICTION.equals(lName)) {
            //current_element_id = NEXTBUSPREDICTION_ID;
        } else if (NEXTBUSRESPONSE.equals(lName)) {
            //current_element_id = NEXTBUSRESPONSE_ID;
        } else if (PREDICTIONS.equals(lName)) {
            //current_element_id = PREDICTIONS_ID;
        } else if (ROUTEID.equals(lName)) {
            //current_element_id = ROUTEID_ID;
        } else if (STOPNAME.equals(lName)) {
            //current_element_id = STOPNAME_ID;
        } else if (VEHICLEID.equals(lName)) {
            //current_element_id = VEHICLEID_ID;
        }
    }

    @Override
    public void characters(final char[] ch, final int start, final int length) {
        buff.append(ch, start, length); //XXX
    }
}
